<?php

use App\Http\Controllers\Api\AuthController;
use App\Http\Controllers\Api\CarOwnerController;
use App\Http\Controllers\Api\ScanController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

// 公开路由
Route::post('/auth/login', [AuthController::class, 'login'])->name('auth.login');

// 需要认证的路由
Route::middleware('auth:sanctum')->group(function () {
    // 用户信息相关
    Route::post('/auth/user-info', [AuthController::class, 'updateUserInfo'])->name('auth.updateUserInfo');
    Route::get('/user/profile', [AuthController::class, 'getUserProfile'])->name('user.profile');
    
    // 车主信息相关
    Route::post('/car-owner/phone', [CarOwnerController::class, 'savePhoneNumber'])->name('carOwner.savePhone');
    Route::get('/car-owner/qrcode', [CarOwnerController::class, 'getQrCode'])->name('carOwner.getQrCode');
    
    // 扫码相关
    Route::post('/scan/decode', [ScanController::class, 'decodeQrCode'])->name('scan.decode');
    Route::post('/scan/call-log', [ScanController::class, 'logCallMade'])->name('scan.logCall');
});
